const express = require('express');
const router = express.Router();
const systemController = require('../controllers/systemController');
const { authenticate, authorize } = require('../middlewares/auth');
const { authMiddleware } = require('../middlewares/auth');

// 应用认证中间件
router.use(authMiddleware);

// 获取系统状态
router.get('/status', authenticate, authorize(['admin']), systemController.getSystemStatus);

// 获取系统资源使用情况
router.get('/resources', authenticate, authorize(['admin', 'manager']), systemController.getSystemResources);

// 重启前端容器
router.post('/restart/frontend', authenticate, authorize(['admin']), systemController.restartFrontend);

// 重启后端容器
router.post('/restart/backend', authenticate, authorize(['admin']), systemController.restartBackend);

// 重启Nginx容器
router.post('/restart/nginx', authenticate, authorize(['admin']), systemController.restartNginx);

// 获取系统日志
router.get('/logs/:containerType', authMiddleware, systemController.getContainerLogs);

// 以下Docker容器日志相关路由已禁用
/*
// 获取Docker容器列表
router.get('/docker/containers', authenticate, authorize(['admin']), systemController.getDockerContainers);

// 获取Docker容器日志
router.get('/docker/logs/:containerId', authenticate, authorize(['admin']), systemController.getDockerContainerLogs);
*/

module.exports = router; 